// pages/home/home.js
const images = require('../../utils/images.js')
const {
  createUser,
  getUserInfo
} = require("../../utils/api")
const to = require("../../utils/jump")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
    catalogSelect: 0,
    navigateList: [
      {
        id: 0,
        name: "龙珠系列",
        select: 0
      },
      {
        id: 1,
        name: "高达系列",
        select: 1
      },
      {
        id: 2,
        name: "一人之下",
        select: 2
      },
      {
        id: 3,
        name: "鬼刀系列",
        select: 3
      },
      {
        id: 4,
        name: "火影系列",
        select: 4
      }
    ],
    allGood: [
      {
        src: "../../images/home/card.png",
        type: 0,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 2,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 1,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 2,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 0,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 1,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 1,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
      {
        src: "../../images/home/card.png",
        type: 2,
        name: "【元神系列】矿难模式",
        price: "9.9"
      },
    ],
    indicatorDots: true,
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    imgs: {},//图片资源
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getimgs()
    this.getUser()
    // images.gethome(() => {this.getimgs})
    // createUser({nickname:"9999",})
  },
  getimgs() {
    this.setData({
      imgs: {
        home0: wx.getStorageSync('home0'),
        home10: wx.getStorageSync('home1'),
        home2: wx.getStorageSync('home2'),
        home3: wx.getStorageSync('home3'),
        home4: wx.getStorageSync('home4'),
        home5: wx.getStorageSync('home5'),
        home6: wx.getStorageSync('home6'),
        home7: wx.getStorageSync('home7'),
        all: wx.getStorageSync('home8'),
        card: wx.getStorageSync('home9'),
        quan: wx.getStorageSync('home10'),
        quanjushang: wx.getStorageSync('home11'),
        tabbg: wx.getStorageSync('home12'),
        wu: wx.getStorageSync('home13'),
        wuxianchi: wx.getStorageSync('home14'),
        yi: wx.getStorageSync('home15'),
        yifanshang: wx.getStorageSync('home16'),
        yuan1: wx.getStorageSync('home17'),
        yuan2: wx.getStorageSync('home18'),
      }
    })
  },
  //获取用户信息
  async getUser() {
    const res = await getUserInfo();
    // console.log(res)
  },
  // 多选搜索
  chooseCatalog(data) {
    this.setData({ //把选中值放入判断值
      catalogSelect: data.currentTarget.dataset.select
    })
  },
  //每日转盘
  goTurn() {
    to("/wanfa/pages/daZhuanPan/daZhuanPan")
  },
  goTask() {
    to("/wanfa/pages/meiRiRenWu/meiRiRenWu")
  },
  goYiFanShang() {
    to("/wanfa/pages/yiFanShang/yiFanShang")
  },
  goQuanJuShang() {
    to("/wanfa/pages/quanjushang/quanjushang")
  },
  goWuXianChi() {
    to("/wanfa/pages/wuxianchi/wuxianchi")
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})